Add specs for `interpolation_context#[]=` and `interpolate_with`.

Akinori MUSHA 10 years ago
parent
commit
2b493f548b
1 changed files with 29 additions and 0 deletions
  1. 29 0
      spec/support/shared_examples/liquid_interpolatable.rb

+ 29 - 0
spec/support/shared_examples/liquid_interpolatable.rb

@@ -54,6 +54,35 @@ shared_examples_for LiquidInterpolatable do
54 54
       @checker.interpolate_string("{{variable}}", @event).should == "hello"
55 55
       @checker.interpolate_string("{{variable}} you", @event).should == "hello you"
56 56
     end
57
+
58
+    it "should use local variables while in a block" do
59
+      @checker.options['locals'] = '{{_foo_}} {{_bar_}}'
60
+
61
+      @checker.interpolation_context.tap { |context|
62
+        @checker.interpolated['locals'].should == ' '
63
+
64
+        context.stack {
65
+          context['_foo_'] = 'This is'
66
+          context['_bar_'] = 'great.'
67
+
68
+          @checker.interpolated['locals'].should == 'This is great.'
69
+        }
70
+
71
+        @checker.interpolated['locals'].should == ' '
72
+      }
73
+    end
74
+
75
+    it "should use another self object while in a block" do
76
+      @checker.options['properties'] = '{{_foo_}} {{_bar_}}'
77
+
78
+      @checker.interpolated['properties'].should == ' '
79
+
80
+      @checker.interpolate_with({ '_foo_' => 'That was', '_bar_' => 'nice.' }) {
81
+        @checker.interpolated['properties'].should == 'That was nice.'
82
+      }
83
+
84
+      @checker.interpolated['properties'].should == ' '
85
+    end
57 86
   end
58 87
 
59 88
   describe "liquid tags" do